package com.rising.face.ali.bishi.department;

import java.util.LinkedList;
import java.util.List;

/**
 * @Author: rising
 * @Description:
 * @Date: create in 2021/2/28 15:25
 */
public class DepartmentDao {


    public void delete(Integer departmentId) {
        // 判断是否有子部门
        List<Integer> sunDepartmentIdList = getSunDepartmentIdList(departmentId);
        if (!sunDepartmentIdList.isEmpty()) {
            for (int sunDepartmentId : sunDepartmentIdList) {
                // 递归删除子部门
                delete(sunDepartmentId);
            }
        }
        // 删除本部门数据
        deleteDepartment(departmentId);
    }


    public List<Integer> getSunDepartmentIdList(int departmentId) {

        //伪代码
        List<Integer> sunDepartmentIdList = new LinkedList<>();//这里要从数据库里面查找
        if (sunDepartmentIdList == null) {
            sunDepartmentIdList = new LinkedList<>();
        }
        return sunDepartmentIdList;
    }

    public void deleteDepartment(int departmentId) {
        //删除部门信息
    }

}
